//
// io.h
// Usage: I/O Routines
// Create Date: 2009-01-31
// Creator: MaJiuyue
//
#ifndef _IO_H_
#define _IO_H_

#define insw(port,buf,nr) \
__asm__("cld;rep;insw"::"d" (port),"D" (buf),"c" (nr))

#define outsw(port,buf,nr) \
__asm__("cld;rep;outsw"::"d" (port),"D" (buf),"c" (nr))

#define _outp(port,value) \
__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))

#define _inp(port) ({ \
unsigned char _v; \
__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
_v; \
})

#define outb(port,value) _outp(port,value)
#define inb(port) _inp(port)

#define outw(port,value) \
__asm__("outw %%ax,%%dx"::"a"(value),"d"(port))

#define inw(port) ({	\
unsigned short _v;	\
__asm__ volatile("inw %%dx,%%ax":"=a"(_v):"d"(port)); \
_v; \
})

#endif

